Skip to content

feat(java): optimize json perf#3871

Open
chaokunyang wants to merge 9 commits into
apache:mainfrom
chaokunyang:optimize_json_perf
Open

feat(java): optimize json perf#3871
chaokunyang wants to merge 9 commits into
apache:mainfrom
chaokunyang:optimize_json_perf

Conversation

@chaokunyang

@chaokunyang chaokunyang commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Why?

What does this PR do?

Related issues

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes / no
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, my PR description includes the required ai_review summary and screenshot evidence or equivalent persisted links of the final clean AI review results from both fresh reviewers described in AI_POLICY.md, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes.

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

Route complete codec and generated member-group calls through shared polymorphic trampoline sites so C2 cannot recursively absorb the full writer graph while group-local scalar calls still inline.\n\nOpenJDK 25 JsonSerializationSuite.foryToJsonBytes: 10.317M ops/s, 504.000 B/op. Full fory-json suite: 742 tests passed.
Keep handwritten and root codec dispatch direct, and let generated object writers choose shared C2 boundaries from representation-aware resolved subtree cost.

JDK 25 MediaContent: UTF-8 10.440M -> 10.502M ops/s at 504 B/op; String 6.916M -> 6.982M ops/s at 528 B/op. The Users/Clients serialization screen had no regression over 1%. All 743 fory-json tests, Spotless, and Checkstyle pass.
Keep large generated read/write subtrees behind codegen-owned call boundaries, let generated roots own eligible object collection loops, and preserve compact Latin1 string leaves behind a real medium writer boundary. Handwritten codecs, readers, writers, and roots remain direct.

JDK 25 Users 1000KB serialization: Fory 11,887.815 ops/s vs Wast 10,714.921 ops/s (+10.95%), with effectively zero allocation. Full Java reactor and fory-json tests pass; Spotless and Checkstyle pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants